<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/7/31 0031
 * Time: 下午 2:25
 */
namespace app\back\controller;
use app\model\Places;

class School extends  \app\back\controller\BaseAdmin{

    function set_model()
    {
        $this->model=new \app\model\School();
    }

    function list_init()
    {
        $model=$this->get_model();
        return [

            'title'=>'学校',
            'list_title'=>['ID','学校名字'],
            'list_data_name'=>['id','school_name'],
            'list_data'=>$model->order("id","desc")->paginate(),
            'page_html'=>$model->paginate()->render(),
            'add_url'=>url('add')

        ];
    }

    function edit_init($id)
    {
        $model=$this->get_model();
        $info=$model->where(['id'=>$id])->find();

        $Places=new Places();
        $arrs=$Places->get_province();
        $arrs2=get_key_arr_by_arrs($arrs,'id','cname');



        return [
            'form'=>[
                ['name'=>'id','value'=>$info->id,'type'=>'hidden','label_title'=>""],
                ['name'=>'school_name','value'=>$info->school_name,'type'=>'text','label_title'=>"学校名字"],
                ['name'=>'p_id','value'=>$info->p_id,'type'=>'select','label_title'=>'省','arrs'=>$arrs2],
                ['name'=>'edu_type','value'=>$info->edu_type,'type'=>'select','label_title'=>'学历','arrs'=>config('web.school_edu_type')],
                ['name'=>'pic','value'=>$info->pic,'type'=>'pic_upload','label_title'=>'图片'],
            ],
            'form_action'=>url("edit_act"),
        ];
    }

    function add_init()
    {
        $Places=new Places();
        $arrs=$Places->get_province();
        $arrs2=get_key_arr_by_arrs($arrs,'id','cname');

        return [
            'form'=>[

                ['name'=>'school_name','value'=>'','type'=>'text','label_title'=>"学校名字"],
                ['name'=>'p_id','value'=>'','type'=>'select','label_title'=>'省','arrs'=>$arrs2],
                ['name'=>'edu_type','value'=>'','type'=>'select','label_title'=>'学历','arrs'=>config('web.school_edu_type')],
                ['name'=>'pic','value'=>'','type'=>'pic_upload','label_title'=>'图片'],

            ],
            'form_action'=>url("add_act"),
        ];
    }
}